﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="Cronologia_Movimenti.aspx.cs" Inherits="FimetContoDeposito.Operazioni.Cronologia_Movimenti" %>

<%@ Register assembly="GrayParrot.Web.Controls" namespace="GrayParrot.Web.Controls" tagprefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <asp:PlaceHolder ID="PlaceHolder1" runat="server">        
        <%: Styles.Render("~/bundles/Datatables/css") %>
        <%: Scripts.Render("~/bundles/Datatables") %>
        <%: Styles.Render("~/bundles/Formly/css") %>
        <%: Scripts.Render("~/bundles/Formly") %>
    </asp:PlaceHolder>

    <script type="text/javascript" lang="javascript" src="../Scripts/Formly/FormlyHelper.js"></script>
    <script type="text/javascript" lang="javascript" src="../Scripts/GrayParrot.Core.js"></script> 
    <script type="text/javascript" lang="javascript" src="../Scripts/GrayParrot.AngularJS.Directives.Fileupload.js"></script> 
    <script type="text/javascript" lang="javascript" src="../Scripts/GrayParrot.AngularJS.Directives.DateTimePicker.js"></script> 
    <script type="text/javascript" lang="javascript" src="../Scripts/GrayParrot.AngularJS.js"></script> 
    <script type="text/javascript" lang="javascript" src="../Scripts/GrayParrot.DataTables.js"></script> 
    <script type="text/javascript" lang="javascript" src="../Scripts/GrayParrot.Modals.js"></script> 

<%--    <link type="text/css" rel="stylesheet" href="../Styles/DataTables_Container.css" />--%>
    <style>
        /* http://the-echoplex.net/flexyboxes/?fixed-height=on&display=inline-flex&flex-direction=row&flex-wrap=wrap&justify-content=flex-start&align-items=baseline&align-content=flex-start&order%5B%5D=0&flex-grow%5B%5D=0&flex-shrink%5B%5D=1&flex-basis%5B%5D=auto&align-self%5B%5D=auto&order%5B%5D=0&flex-grow%5B%5D=0&flex-shrink%5B%5D=1&flex-basis%5B%5D=auto&align-self%5B%5D=auto&order%5B%5D=0&flex-grow%5B%5D=0&flex-shrink%5B%5D=1&flex-basis%5B%5D=auto&align-self%5B%5D=auto&order%5B%5D=0&flex-grow%5B%5D=0&flex-shrink%5B%5D=1&flex-basis%5B%5D=auto&align-self%5B%5D=auto&order%5B%5D=0&flex-grow%5B%5D=0&flex-shrink%5B%5D=1&flex-basis%5B%5D=auto&align-self%5B%5D=auto&order%5B%5D=0&flex-grow%5B%5D=0&flex-shrink%5B%5D=1&flex-basis%5B%5D=auto&align-self%5B%5D=auto&order%5B%5D=0&flex-grow%5B%5D=0&flex-shrink%5B%5D=1&flex-basis%5B%5D=auto&align-self%5B%5D=auto&order%5B%5D=0&flex-grow%5B%5D=0&flex-shrink%5B%5D=1&flex-basis%5B%5D=auto&align-self%5B%5D=auto&order%5B%5D=0&flex-grow%5B%5D=0&flex-shrink%5B%5D=1&flex-basis%5B%5D=auto&align-self%5B%5D=auto&order%5B%5D=0&flex-grow%5B%5D=0&flex-shrink%5B%5D=1&flex-basis%5B%5D=auto&align-self%5B%5D=auto */
        /* http://stackoverflow.com/questions/20743434/how-to-wrap-a-div-vertically-and-then-horizontally */

        .externaly_triggered_wrapper {
            display: -ms-inline-flexbox;
            display: -webkit-inline-flex;
            display: inline-flex;
            -webkit-flex-direction: row;
            -ms-flex-direction: row;
            flex-direction: row;
            -webkit-flex-wrap: wrap;
            -ms-flex-wrap: wrap;
            flex-wrap: wrap;
            -webkit-justify-content: flex-start;
            -ms-flex-pack: start;
            justify-content: flex-start;
            -webkit-align-content: flex-start;
            -ms-flex-line-pack: start;
            align-content: flex-start;
            -webkit-align-items: baseline;
            -ms-flex-align: baseline;
            align-items: baseline;
            width:800px;
            }

        .externaly_triggered_wrapper div {
            -webkit-order: 0;
            -ms-flex-order: 0;
            order: 0;
            -webkit-flex: 0 1 auto;
            -ms-flex: 0 1 auto;
            flex: 0 1 auto;
            -webkit-align-self: auto;
            -ms-flex-item-align: auto;
            align-self: auto;
            padding:1px 1px 1px 1px;
            }
    </style>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <!-- 
        Sitemap Menu item:
        <siteMapNode url="~/Cronologia_Movimenti.aspx" title="Cronologia_Movimenti" description="Cronologia_Movimenti" image="fa-laptop" id="Cronologia_Movimenti"/>
    -->
    <section class="panel">
	    <header class="panel-heading">
			<b>Cronologia Movimenti</b>
		</header>

        <a class="collapsed" data-toggle="collapse" href="#collapseSetting">
            <h4 class="fa  fa-search"> Filters</h4>
        </a>
        <section id="collapseSetting" class="collapse" style="height: 0px;">
            <div class="collapse-boby" style="padding:0">
                <% HttpContext.Current.Response.Write(this.JQDTable.RenderExternalFilters()); %>
            </div>
        </section>

		<div class="panel-body">

            <!-- PUT YOUR CONTENT HERE -->
            <iframe id='iframeCrud' frameborder="0" style="width:800px; height:450px; display:none"></iframe>
            <div id="crudDialog" title="" style="display:none"></div>

                <div class="row">
                    <div class="col-lg-12">
                        <section class="panel">
							<header class="panel-heading">
                            <div ng-app="formlyExample" ng-controller="MainCtrl as vm" name="divContainer" id="div1">
                                <div ng-if="vm.loadingData.$$state.status === 0" style="margin:20px 0;font-size:2em">
                                    <strong>Caricamento...</strong>
                                </div>
                                <div ng-if="vm.loadingData.$$status.state !== 0">
                                    <form ng-submit="vm.onSubmit()" novalidate id="form1">
                                        <formly-form model="vm.model" fields="vm.fields" form="vm.form">
                                        </formly-form>
                                    </form>
                                </div>
                            </div>
							</header>  
                            <div class="panel-body">
                                <cc1:JQDataTable ID="JQDTable" runat="server" 
                                     SelectionMode="Single" 
                                     RenderScripts="false" 
                                     BootstrapClasses="table table-hover table-bordered table-condensed">
                                    <FeaturesConfig>
                                        <Features>
                                            <cc1:Searching Value="Both" ExternalFilters="true">
                                                <Filters>
                                                    <cc1:TextColumnFilter ColumnName="numero_documento" DefaultLabel="N. Documento"  />
                                                    <cc1:DateColumnFilter ColumnName="data_documento" DefaultLabel="Data Documento" DateFormat="dd/mm/yyyy" />
                                                    <cc1:SelectColumnFilter ColumnName="tipo_documento" DefaultLabel="Tipo Documento" 
                                                                          Url ="/api/Common/LoadTipoDocumento" SelectType="Simple" TextProp="name" IdProp="value" Width="200" />
                                                    <cc1:TextColumnFilter ColumnName="ragione_sociale" DefaultLabel="Magazzino"  />
                                                    <cc1:TextColumnFilter ColumnName="riferimento_cliente" DefaultLabel="Rif. Cli."   />
                                                    <cc1:DateColumnFilter ColumnName="data_registrazione" DefaultLabel="Data Registrazione" DateFormat="dd/mm/yyyy"  />
                                                    <cc1:SelectColumnFilter ColumnName="mov" DefaultLabel="Tipo Movimento"
                                                                          Url ="/api/Common/LoadTipoMovimento" SelectType="Simple" TextProp="name" IdProp="value" Width="200" />
                                                    <cc1:DateColumnFilter ColumnName="data_consegna" DefaultLabel="Data Consegna" DateFormat="dd/mm/yyyy" />
                                                    <cc1:TextColumnFilter ColumnName="stato" DefaultLabel="Stato" />  
                                                    <cc1:SelectColumnFilter ColumnName="priorita" DefaultLabel="Priorita"
                                                                          Url ="/api/Common/LoadPriorita" SelectType="Simple" TextProp="name" IdProp="value" Width="200" />
                                                    <cc1:TextColumnFilter ColumnName="colore" DefaultLabel="Colore" />
                                                    <cc1:TextColumnFilter ColumnName="serie_famiglia" DefaultLabel="Serie Famiglia"  />
                                                    <cc1:TextColumnFilter ColumnName="codice_articolo" DefaultLabel="Cod. Articolo" />
                                                    <cc1:TextColumnFilter ColumnName="descrizione_articolo" DefaultLabel="Descr. Articolo" />
                                                    <cc1:CustomChoiceFilter ColumnName="is_xxxx" DefaultLabel="Codice XXXX" FilterDefaultLabel="seleziona...">
                                                         <Data>
                                                            <cc1:DataItem name="Tutti" value="0" />
                                                            <cc1:DataItem name="Si" value="1" />
                                                            <cc1:DataItem name="No" value="2" />
                                                        </Data>
                                                    </cc1:CustomChoiceFilter>
                                                </Filters>
                                            </cc1:Searching>
                                            <cc1:AutoWitdh Value="true" />
                                            <cc1:ScrollY Value="500" ScrollCollapse="true" />
                                            <cc1:ScrollX Value="600" />
                                            <cc1:LengthChange Value="false" />
                                            <cc1:Paging PagingType="FullNumbers" PageLength="20" />
                                        </Features>
                                    </FeaturesConfig>
                                    <ControllerConfig Url="/api/CronologiaMovimenti/LoadMovimenti" LoadingMode="OnDemand">
                                        <Validation Message="Inserire i parametri" FormId="form1" />
                                        <ControllerParameters>
                                            <cc1:ControllerParameter Name="formly_1_asyncselect_selMagazzini_0" Alias="Customer" />
                                        </ControllerParameters>
                                    </ControllerConfig>
                                    <ColumnsConfig Key="Id">
                                        <Columns>
                                            <cc1:TextColumn Name="Id" Header="Id" Visible="false" />
                                            <cc1:TextColumn Name="numero_documento" Header="N.Doc" Width="150" />
                                            <cc1:DateColumn Name="data_documento" Header="Data Doc." Width="150" />
                                            <cc1:TextColumn Name="tipo_documento" Header="T. Doc" Width="60"/>
                                            <cc1:TextColumn Name="ragione_sociale" Header="Magazzino" Width="250" />
                                            <cc1:TextColumn Name="riferimento_cliente" Header="Rif.Cli." Width="50" />
                                            <cc1:DateColumn Name="data_registrazione" Header="Data Reg." Width="150" />
                                            <cc1:TextColumn Name="mov" Header="Mov" Width="20" />
                                            <cc1:DateColumn Name="data_consegna" Header="Data Cons." Width="150" />
                                            <cc1:TextColumn Name="note" Header="Note" Width="60" />        
                                            <cc1:BooleanColumn Name="stato" Header="Stato" Width="60" />                                 
                                            <cc1:BooleanColumn Name="priorita" Header="Prio." Width="60"  />
                                            <cc1:TextColumn Name="colore" Header="Colore" Width="60" />
                                            <cc1:TextColumn Name="serie_famiglia" Header="S.Fam." Width="60" />
                                            <cc1:TextColumn Name="sigla" Header="T.Art." Width="60" />
                                            <cc1:TextColumn Name="codice_articolo" Header="Cod.Art." Width="60" />
                                            <cc1:TextColumn Name="descrizione_articolo" Header="Descr.Art" Width="160" />
                                            <cc1:TextColumn Name="dimensioni" Header="Dim." Width="60" />
                                            <cc1:TextColumn Name="codice_fornitore" Header="Cod.Forn." Width="60" />
                                            <cc1:TextColumn Name="note_articolo" Header="Note Art." Width="60" />
                                            <cc1:TextColumn Name="qta_pacco" Header="Qta Pacco" Width="60" />
                                            <cc1:TextColumn Name="peso_teorico" Header="P.Teorico" Width="60" />
                                            <cc1:TextColumn Name="UMGrz" Header="UM. Grz" Width="60" />
                                            <cc1:TextColumn Name="QTAGrz" Header="Qta Grz" Width="60" />
                                            <cc1:TextColumn Name="movimento_kg" Header="Mpv.Kg" Width="60" />
                                            <cc1:TextColumn Name="f_lotto" Header="F.Lotto" Width="60" />
                                            <cc1:TextColumn Name="um_fatt" Header="UM. Fatt." Width="60" />
                                            <cc1:TextColumn Name="qta_fatt" Header="Qta Fatt." Width="60" />
                                            <cc1:TextColumn Name="prezzo_unitario" Header="P.Unitario" Width="60" />
                                            <cc1:TextColumn Name="numero_documento_carico" Header="N.Doc. Carico" Width="60" />
                                            <cc1:DateColumn Name="data_documento_carico" Header="Data Doc. Carico" Width="60" />
                                            <cc1:TextColumn Name="tipo_documento_carico" Header="T. Doc. Carico" Width="60" />
                                            <cc1:TextColumn Name="fornitore_carico" Header="Forn. Carico" Width="60" />
                                            <cc1:BooleanColumn Name="is_xxxx" Header="" Width="50" />
                                            <cc1:ActionColumn Header="Azioni" >
                                                <Actions>
                                                    <cc1:ActionIcon Icon="fa fa-search" Callback="ShowImage" />
                                                    <cc1:ActionIcon Icon="fa fa-pencil" Callback="EditCallback" />
                                                    <cc1:ActionIcon Icon="fa fa-trash-o" Callback="DeleteCallback" />
                                                </Actions>
                                            </cc1:ActionColumn>
                                        </Columns>
                                    </ColumnsConfig>
                                    <Buttons>
                                        <cc1:UtilityButton Text="Excel" Type="ExportToExcel" Title="Cronologia"  />
                                    </Buttons>
                                </cc1:JQDataTable>
                                <%--</div>--%>
                            </div>                      
                        </section>
                    </div>
                </div>
		</div>
	</section>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="LocaJavascript" runat="server">
    <% HttpContext.Current.Response.Write(this.JQDTable.RenderScriptsManually()); %>

<script>
    $(document).ready(function () {
        // BOOTSTRAP: Tweaks
        $('.yadcf-filter-wrapper').addClass('input-group');
        $('.yadcf-filter, .yadcf-filter-date', this).addClass('form-control input-sm form-inline');
        $('.yadcf-filter-reset-button', this).addClass('btn btn-default btn-sm').wrap('<span class="input-group-btn"></span>');
    });

    var settings = new FormlySettings();
    settings.container = '#divFormly';
    settings.setLoad(settings.createGetConfig('/api/CronologiaMovimenti/LoadCustomersFields'));
    FormlyManager(settings);

    /* */
    function ShowImage(obj) {
        $("#iframeCrud").prop('src', '/operazioni/ShowImage.aspx?id=' + obj.IdArticolo).appendTo("#crudDialog");
        $("#iframeCrud").width(800);
        $("#iframeCrud").height(450);
        $("#iframeCrud").show();

        m_dialog = $("#crudDialog").dialog({
            title: 'Dettaglio Articolo',
            width: 'auto',
            height: 'auto',
            modal: true,
            close: function () {
                $("#iframeCrud").width(1000);
                $("#iframeCrud").height(550);
                $("#iframeCrud").contents().remove();
                $('#iframeCrud').hide();
            }
        });
    }
</script>
</asp:Content>